package com.sailfish.springbootdemo.dao.db1;

import com.sailfish.springbootdemo.common.DB1TableName;
import com.sailfish.springbootdemo.pojo.db1.PcbaDevice;
import com.sailfish.springbootdemo.pojo.db1.PcbaDeviceAudit;
import com.sailfish.springbootdemo.pojo.db1.PcbaDeviceResource;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.Date;
import java.util.List;

public interface PcbaDeviceDao {

    /**
     * 查询所有
     *
     * @param pcbaDeviceTypeId
     * @param searchValue
     * @return
     */
    @Results(id = "pcbaDeviceResultMap", value = {
            @Result(column = "pcba_device_id", property = "pcbaDeviceId", jdbcType = JdbcType.INTEGER),
            @Result(column = "pcba_device_name_cn", property = "pcbaDeviceNameCn", jdbcType = JdbcType.VARCHAR),
            @Result(column = "pcba_device_name_en", property = "pcbaDeviceNameEn", jdbcType = JdbcType.VARCHAR),
            @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.DATETIMEOFFSET),
            @Result(column = "update_time", property = "updateTime", jdbcType = JdbcType.DATETIMEOFFSET),
            @Result(column = "status", property = "status", jdbcType = JdbcType.INTEGER),
            @Result(column = "pcba_device_type_id", property = "pcbaDeviceTypeId", jdbcType = JdbcType.INTEGER),
            @Result(column = "sort", property = "sort", jdbcType = JdbcType.INTEGER),
            @Result(column = "pcba_line_id", property = "pcbaLineId", jdbcType = JdbcType.INTEGER),
            @Result(column = "pcba_device_resource_id", property = "pcbaDeviceResourceId", jdbcType = JdbcType.INTEGER),
            @Result(column = "asset_number", property = "assetNumber", jdbcType = JdbcType.VARCHAR),
            @Result(column = "product_time", property = "productTime", jdbcType = JdbcType.DATETIMEOFFSET),
            @Result(column = "purpose", property = "purpose", jdbcType = JdbcType.VARCHAR),
            @Result(column = "begin_time", property = "beginTime", jdbcType = JdbcType.DATETIMEOFFSET),
            @Result(column = "end_time", property = "endTime", jdbcType = JdbcType.DATETIMEOFFSET),
            @Result(column = "is_filled_tech_params_actual", property = "isFilledTechParamsActual", jdbcType = JdbcType.INTEGER),
            @Result(column = "params_status", property = "paramsStatus", jdbcType = JdbcType.INTEGER),
            @Result(column = "is_filled_upkeep", property = "isFilledUpkeep", jdbcType = JdbcType.INTEGER),
            @Result(column = "upkeep_status", property = "upkeepStatus", jdbcType = JdbcType.INTEGER),
            @Result(column = "params_notes", property = "paramsNotes", jdbcType = JdbcType.VARCHAR),
            @Result(column = "submitter", property = "submitter", jdbcType = JdbcType.INTEGER),
            @Result(column = "auditors", property = "auditors", jdbcType = JdbcType.VARCHAR),
            @Result(column = "loop_close_status", property = "loopCloseStatus", jdbcType = JdbcType.INTEGER),
            @Result(column = "loop_close_time", property = "loopCloseTime", jdbcType = JdbcType.DATETIMEOFFSET),
            @Result(column = "loop_close_user", property = "loopCloseUser", jdbcType = JdbcType.INTEGER),
            @Result(column = "loop_close_last_send_time", property = "loopCloseLastSendTime", jdbcType = JdbcType.DATETIMEOFFSET),
            @Result(column = "age_close_status", property = "ageCloseStatus", jdbcType = JdbcType.INTEGER),
            @Result(column = "age_close_time", property = "ageCloseTime", jdbcType = JdbcType.DATETIMEOFFSET),
            @Result(column = "age_close_user", property = "ageCloseUser", jdbcType = JdbcType.INTEGER),
            @Result(column = "age_close_last_send_time", property = "ageCloseLastSendTime", jdbcType = JdbcType.DATETIMEOFFSET),
            @Result(column = "age_close_flag", property = "ageCloseFlag", jdbcType = JdbcType.INTEGER),
            @Result(column = "loop_close_remark", property = "loopCloseRemark", jdbcType = JdbcType.VARCHAR),
            @Result(column = "loop_close_files", property = "loopCloseFiles", jdbcType = JdbcType.VARCHAR),
            @Result(column = "age_close_remark", property = "ageCloseRemark", jdbcType = JdbcType.VARCHAR),
            @Result(column = "age_close_files", property = "ageCloseFiles", jdbcType = JdbcType.VARCHAR),
            @Result(column = "loop_close_audit_reason", property = "loopCloseAuditReason", jdbcType = JdbcType.VARCHAR),
            @Result(column = "age_close_audit_reason", property = "ageCloseAuditReason", jdbcType = JdbcType.VARCHAR),
            @Result(column = "loop_close_method", property = "loopCloseMethod", jdbcType = JdbcType.INTEGER),
            @Result(column = "age_close_method", property = "ageCloseMethod", jdbcType = JdbcType.INTEGER),
            @Result(column = "loop_close_uuid", property = "loopCloseUuid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "age_close_uuid", property = "ageCloseUuid", jdbcType = JdbcType.VARCHAR),
    })
    @Select("<script>" +
            "select t1.* from " + DB1TableName.PCBA_DEVICE + " t1 left join " + DB1TableName.PCBA_LINE + " t2 on t1.pcba_line_id = t2.pcba_line_id where 1 = 1 " +
            "<if test='pcbaDeviceTypeId != null and pcbaDeviceTypeId != \"\" '>" +
            " and t1.pcba_device_type_id = #{pcbaDeviceTypeId} " +
            "</if>" +
            "<if test='searchValue != null and searchValue != \"\" '>" +
            " and (t1.pcba_device_name_cn like CONCAT('%',#{searchValue},'%') or t1.pcba_device_name_en like CONCAT('%',#{searchValue},'%') or t1.asset_number like CONCAT('%',#{searchValue},'%'))" +
            "</if>" +
            "<if test='status != null and status != \"\" '>" +
            " and t1.status = #{status} " +
            "</if>" +
            "<if test='pcbaCompanyId != null and pcbaCompanyId != \"\" '>" +
            " and t2.pcba_company_id = #{pcbaCompanyId} " +
            "</if>" +
            "<if test='pcbaWorkshopId != null and pcbaWorkshopId != \"\" '>" +
            " and t2.pcba_workshop_id = #{pcbaWorkshopId} " +
            "</if>" +
            "<if test='pcbaProcessId != null and pcbaProcessId != \"\" '>" +
            " and t2.pcba_process_id = #{pcbaProcessId} " +
            "</if>" +
            "<if test='isFilledUpkeep != null and isFilledUpkeep != \"\" '>" +
            " and t1.is_filled_upkeep = #{isFilledUpkeep} " +
            "</if>" +
            "<if test=\"companyIdList != null and companyIdList.size() > 0 \">\n" +
            "                and t2.pcba_company_id in\n" +
            "                <foreach item=\"item\" index=\"index\" collection=\"companyIdList\"\n" +
            "                         open=\"(\" separator=\",\" close=\")\">\n" +
            "                    #{item}\n" +
            "                </foreach>\n" +
            "            </if>\n" +
            " order by t1.sort" +
            "<if test='begin != null and pageSize != null and pageSize != \"\" '>" +
            " limit #{begin}, #{pageSize}" +
            "</if>" +
            "</script>")
    List<PcbaDevice> getAllPcbaDevice(@Param("pcbaDeviceTypeId") Integer pcbaDeviceTypeId, @Param("searchValue") String searchValue, @Param("status") Integer status, @Param("begin") Integer begin, @Param("pageSize") Integer pageSize, @Param("pcbaCompanyId") Integer pcbaCompanyId, @Param("pcbaWorkshopId") Integer pcbaWorkshopId, @Param("pcbaProcessId") Integer pcbaProcessId, @Param("isFilledUpkeep") Integer isFilledUpkeep, @Param("companyIdList") List<Integer> companyIdList);

    /**
     * 根据id查询
     *
     * @param pcbaDeviceId
     * @return
     */
    @ResultMap(value = "pcbaDeviceResultMap")
    @Select("select * from " + DB1TableName.PCBA_DEVICE + " where pcba_device_id = #{pcbaDeviceId}")
    PcbaDevice getById(@Param("pcbaDeviceId") Integer pcbaDeviceId);

    @ResultMap(value = "pcbaDeviceResultMap")
    @Select("select * from " + DB1TableName.PCBA_DEVICE + " where asset_number = #{assetNumber}")
    PcbaDevice getByAssetNumber(@Param("assetNumber") String assetNumber);

    /**
     * 删除
     *
     * @param pcbaDeviceId
     * @return
     */
    @Delete("delete from " + DB1TableName.PCBA_DEVICE + " where pcba_device_id = #{pcbaDeviceId}")
    Integer deleteById(@Param("pcbaDeviceId") Integer pcbaDeviceId);

    /**
     * 新增
     *
     * @param pcbaDevice
     * @return
     */
    @Insert("insert into " + DB1TableName.PCBA_DEVICE + "(pcba_device_name_cn,pcba_device_name_en,create_time,status,pcba_device_type_id,sort,pcba_line_id,pcba_device_resource_id,asset_number,product_time,purpose,is_filled_tech_params_actual,is_filled_upkeep,upkeep_status,params_notes,submitter,auditors) values " +
            "(#{pcbaDevice.pcbaDeviceNameCn},#{pcbaDevice.pcbaDeviceNameEn},#{pcbaDevice.createTime},#{pcbaDevice.status},#{pcbaDevice.pcbaDeviceTypeId},#{pcbaDevice.sort},#{pcbaDevice.pcbaLineId},#{pcbaDevice.pcbaDeviceResourceId},#{pcbaDevice.assetNumber},#{pcbaDevice.productTime},#{pcbaDevice.purpose},#{pcbaDevice.isFilledTechParamsActual},#{pcbaDevice.isFilledUpkeep},#{pcbaDevice.upkeepStatus},#{pcbaDevice.paramsNotes},#{pcbaDevice.submitter},#{pcbaDevice.auditors})")
    // 显式设置主键
    @Options(useGeneratedKeys = true, keyProperty = "pcbaDevice.pcbaDeviceId")
    Integer addPcbaDevice(@Param("pcbaDevice") PcbaDevice pcbaDevice);

    /**
     * 新增
     *
     * @param pcbaDevice
     * @return
     */
    @Insert("insert into " + DB1TableName.PCBA_DEVICE + "(" +
            "pcba_device_id," +
            "pcba_device_name_cn," +
            "pcba_device_name_en," +
            "create_time," +
            "update_time," +
            "status," +
            "pcba_device_type_id," +
            "sort," +
            "pcba_line_id," +
            "pcba_device_resource_id," +
            "asset_number," +
            "product_time," +
            "purpose," +
            "begin_time," +
            "end_time," +
            "is_filled_tech_params_actual," +
            "params_status," +
            "is_filled_upkeep," +
            "upkeep_status," +
            "params_notes," +
            "submitter," +
            "auditors," +
            "loop_close_status," +
            "loop_close_time," +
            "loop_close_user," +
            "loop_close_last_send_time," +
            "age_close_status," +
            "age_close_time," +
            "age_close_user," +
            "age_close_last_send_time," +
            "age_close_flag) values " +
            "(#{pcbaDevice.pcbaDeviceId}," +
            "#{pcbaDevice.pcbaDeviceNameCn}," +
            "#{pcbaDevice.pcbaDeviceNameEn}," +
            "#{pcbaDevice.createTime}," +
            "#{pcbaDevice.updateTime}," +
            "#{pcbaDevice.status}," +
            "#{pcbaDevice.pcbaDeviceTypeId}," +
            "#{pcbaDevice.sort}," +
            "#{pcbaDevice.pcbaLineId}," +
            "#{pcbaDevice.pcbaDeviceResourceId}," +
            "#{pcbaDevice.assetNumber}," +
            "#{pcbaDevice.productTime}," +
            "#{pcbaDevice.purpose}," +
            "#{pcbaDevice.beginTime}," +
            "#{pcbaDevice.endTime}," +
            "#{pcbaDevice.isFilledTechParamsActual}," +
            "#{pcbaDevice.paramsStatus}," +
            "#{pcbaDevice.isFilledUpkeep}," +
            "#{pcbaDevice.upkeepStatus}," +
            "#{pcbaDevice.paramsNotes}," +
            "#{pcbaDevice.submitter}," +
            "#{pcbaDevice.auditors}," +
            "#{pcbaDevice.loopCloseStatus}," +
            "#{pcbaDevice.loopCloseTime}," +
            "#{pcbaDevice.loopCloseUser}," +
            "#{pcbaDevice.loopCloseLastSendTime}," +
            "#{pcbaDevice.ageCloseStatus}," +
            "#{pcbaDevice.ageCloseTime}," +
            "#{pcbaDevice.ageCloseUser}," +
            "#{pcbaDevice.ageCloseLastSendTime}," +
            "#{pcbaDevice.ageCloseFlag}" +
            ")")
    Integer addPcbaDeviceByAllParams(@Param("pcbaDevice") PcbaDevice pcbaDevice);

    /**
     * 更新
     *
     * @param pcbaDevice
     * @return
     */
    @Update("<script>" +
            "update " + DB1TableName.PCBA_DEVICE +
            "<set>" +
            "<if test='pcbaDevice.pcbaDeviceNameCn != null and pcbaDevice.pcbaDeviceNameCn != \"\" '>" +
            " pcba_device_name_cn = #{pcbaDevice.pcbaDeviceNameCn}," +
            "</if>" +
            "<if test='pcbaDevice.pcbaDeviceNameEn != null and pcbaDevice.pcbaDeviceNameEn != \"\" '>" +
            " pcba_device_name_en = #{pcbaDevice.pcbaDeviceNameEn}," +
            "</if>" +
            "<if test='pcbaDevice.updateTime != null '>" +
            " update_time = #{pcbaDevice.updateTime}," +
            "</if>" +
            "<if test='pcbaDevice.status != null and pcbaDevice.status != \"\" '>" +
            " status = #{pcbaDevice.status}," +
            "</if>" +
            "<if test='pcbaDevice.pcbaDeviceTypeId != null and pcbaDevice.pcbaDeviceTypeId != \"\" '>" +
            " pcba_device_type_id = #{pcbaDevice.pcbaDeviceTypeId}," +
            "</if>" +
            "<if test='pcbaDevice.sort != null and pcbaDevice.sort != \"\" '>" +
            " sort = #{pcbaDevice.sort}," +
            "</if>" +
            "<if test='pcbaDevice.pcbaLineId != null and pcbaDevice.pcbaLineId != \"\" '>" +
            " pcba_line_id = #{pcbaDevice.pcbaLineId}," +
            "</if>" +
            "<if test='pcbaDevice.pcbaDeviceResourceId != null and pcbaDevice.pcbaDeviceResourceId != \"\" '>" +
            " pcba_device_resource_id = #{pcbaDevice.pcbaDeviceResourceId}," +
            "</if>" +
            "<if test='pcbaDevice.assetNumber != null and pcbaDevice.assetNumber != \"\" '>" +
            " asset_number = #{pcbaDevice.assetNumber}," +
            "</if>" +
            "<if test='pcbaDevice.productTime != null'>" +
            " product_time = #{pcbaDevice.productTime}," +
            "</if>" +
            "<if test='pcbaDevice.purpose != null '>" +
            " purpose = #{pcbaDevice.purpose}," +
            "</if>" +
            "<if test='pcbaDevice.beginTime != null'>" +
            " begin_time = #{pcbaDevice.beginTime}," +
            "</if>" +
            "<if test='pcbaDevice.endTime != null'>" +
            " end_time = #{pcbaDevice.endTime}," +
            "</if>" +
            "<if test='pcbaDevice.isFilledTechParamsActual != null and pcbaDevice.isFilledTechParamsActual != \"\" '>" +
            " is_filled_tech_params_actual = #{pcbaDevice.isFilledTechParamsActual}," +
            "</if>" +
            "<if test='pcbaDevice.paramsStatus != null and pcbaDevice.paramsStatus != \"\" '>" +
            " params_status = #{pcbaDevice.paramsStatus}," +
            "</if>" +
            "<if test='pcbaDevice.isFilledUpkeep != null and pcbaDevice.isFilledUpkeep != \"\" '>" +
            " is_filled_upkeep = #{pcbaDevice.isFilledUpkeep}," +
            "</if>" +
            "<if test='pcbaDevice.paramsNotes != null'>" +
            " params_notes = #{pcbaDevice.paramsNotes}," +
            "</if>" +
            "<if test='pcbaDevice.submitter != null and pcbaDevice.submitter != \"\" '>" +
            " submitter = #{pcbaDevice.submitter}," +
            "</if>" +
            "<if test='pcbaDevice.auditors != null and pcbaDevice.auditors != \"\" '>" +
            " auditors = #{pcbaDevice.auditors}," +
            "</if>" +
            "</set>" +
            " where pcba_device_id = #{pcbaDevice.pcbaDeviceId}" +
            "</script>")
    Integer updatePcbaDevice(@Param("pcbaDevice") PcbaDevice pcbaDevice);

    /**
     * 根据设备资产修改保养状态字段
     *
     * @param assetNumber
     * @param upkeepStatus
     * @return
     */
    @Update("update " + DB1TableName.PCBA_DEVICE + " set upkeep_status = #{upkeepStatus} where asset_number = #{assetNumber}")
    Integer updateDeviceUpkeepStatus(@Param("assetNumber") String assetNumber, @Param("upkeepStatus") Integer upkeepStatus);

    /**
     * 调整设备的顺序
     *
     * @param pcbaDeviceId
     * @param sort
     * @return
     */
    @Update("update " + DB1TableName.PCBA_DEVICE + " set sort = #{sort} where pcba_device_id = #{pcbaDeviceId}")
    Integer updatePcbaDeviceSort(@Param("pcbaDeviceId") Integer pcbaDeviceId, @Param("sort") Integer sort);

    /**
     * 根据线体id查询设备列表
     *
     * @param pcbaLineId
     * @return
     */
    @Select("select * from " + DB1TableName.PCBA_DEVICE + " where pcba_line_id = #{pcbaLineId} order by sort")
    @ResultMap(value = "pcbaDeviceResultMap")
    List<PcbaDevice> getPcbaDeviceByLine(@Param("pcbaLineId") Integer pcbaLineId);

    /**
     * 根据线体id删除设备
     *
     * @param pcbaLineId
     * @return
     */
    @Delete("delete from " + DB1TableName.PCBA_DEVICE + " where pcba_line_id = #{pcbaLineId}")
    Integer deleteByPcbaLineId(@Param("pcbaLineId") Integer pcbaLineId);

    /**
     * 根据设备资源id查询
     *
     * @param pcbaDeviceResourceId
     * @return
     */
    @Select("select * from " + DB1TableName.PCBA_DEVICE + " where pcba_device_resource_id = #{pcbaDeviceResourceId}")
    @ResultMap(value = "pcbaDeviceResultMap")
    List<PcbaDevice> getPcbaDeviceResourceByPcbaDeviceResourceId(@Param("pcbaDeviceResourceId") Integer pcbaDeviceResourceId);

    /**
     * 设备资产是否唯一
     */
    @Select("select * from " + DB1TableName.PCBA_DEVICE + " where asset_number = #{assetNumber} and pcba_device_id != #{pcbaDeviceId}")
    @ResultMap(value = "pcbaDeviceResultMap")
    List<PcbaDevice> judgeAssetNumber(@Param("assetNumber") String assetNumber, @Param("pcbaDeviceId") Integer pcbaDeviceId);

    /**
     * 修改设备的实际认证能力状态
     */
    @Update("update " + DB1TableName.PCBA_DEVICE + " set params_status = #{paramsStatus} where pcba_device_id = #{pcbaDeviceId}")
    Integer updatePcbaDeviceParamsStatus(@Param("pcbaDeviceId") Integer pcbaDeviceId, @Param("paramsStatus") Integer paramsStatus);

    /**
     * 审核
     *
     * @param paramsNotes
     * @param pcbaDeviceId
     * @param paramsStatus
     * @return
     */
    @Update("update " + DB1TableName.PCBA_DEVICE + " set is_filled_tech_params_actual = #{isFilledTechParamsActual},params_status = #{paramsStatus},params_notes = #{paramsNotes},update_time = #{updateTime} where pcba_device_id = #{pcbaDeviceId}")
    Integer auditPcbaDevice(@Param("isFilledTechParamsActual") Integer isFilledTechParamsActual, @Param("paramsNotes") String paramsNotes, @Param("pcbaDeviceId") Integer pcbaDeviceId, @Param("paramsStatus") Integer paramsStatus, @Param("updateTime") Date updateTime);

    /**
     * 高端线体设备超时闭环修改
     */
    @Update("update " + DB1TableName.PCBA_DEVICE + " set loop_close_status = #{loopCloseStatus},loop_close_user = #{loopCloseUser},loop_close_time = #{loopCloseTime},loop_close_audit_reason = #{loopCloseAuditReason} where pcba_device_id = #{pcbaDeviceId}")
    Integer handleHighLoopCloseOk(@Param("pcbaDeviceId") Integer pcbaDeviceId, @Param("loopCloseStatus") Integer loopCloseStatus, @Param("loopCloseUser") Integer loopCloseUser, @Param("loopCloseTime") Date loopCloseTime,@Param("loopCloseAuditReason")String loopCloseAuditReason);

    @Update("update " + DB1TableName.PCBA_DEVICE + " set loop_close_status = #{loopCloseStatus},loop_close_audit_reason = #{loopCloseAuditReason} where pcba_device_id = #{pcbaDeviceId}")
    Integer handleHighLoopCloseNo(@Param("pcbaDeviceId") Integer pcbaDeviceId, @Param("loopCloseStatus") Integer loopCloseStatus,@Param("loopCloseAuditReason")String loopCloseAuditReason);

    /**
     * 更新设备的闭环上次发邮件时间
     */
    @Update("update " + DB1TableName.PCBA_DEVICE + " set loop_close_last_send_time = #{loopCloseLastSendTime} where pcba_device_id = #{pcbaDeviceId}")
    Integer updateDeviceLoopCloseLastSendTime(@Param("loopCloseLastSendTime") Date loopCloseLastSendTime, @Param("pcbaDeviceId") Integer pcbaDeviceId);

    /**
     * 线体设备年限闭环修改
     */
    @Update("update " + DB1TableName.PCBA_DEVICE + " set age_close_status = #{ageCloseStatus},age_close_user = #{ageCloseUser},age_close_time = #{ageCloseTime},age_close_flag = #{ageCloseFlag} where pcba_device_id = #{pcbaDeviceId}")
    Integer handleAgeLoopCloseOk(@Param("pcbaDeviceId") Integer pcbaDeviceId, @Param("ageCloseStatus") Integer ageCloseStatus, @Param("ageCloseUser") Integer ageCloseUser, @Param("ageCloseTime") Date ageCloseTime, @Param("ageCloseFlag") Integer ageCloseFlag,@Param("ageCloseAuditReason") String ageCloseAuditReason);

    @Update("update " + DB1TableName.PCBA_DEVICE + " set age_close_status = #{ageCloseStatus},age_close_audit_reason = #{ageCloseAuditReason} where pcba_device_id = #{pcbaDeviceId}")
    Integer handleAgeLoopCloseNo(@Param("pcbaDeviceId") Integer pcbaDeviceId, @Param("ageCloseStatus") Integer ageCloseStatus, @Param("ageCloseAuditReason") String ageCloseAuditReason);

    /**
     * 更新线体设备年限上次发邮件时间
     */
    @Update("update " + DB1TableName.PCBA_DEVICE + " set age_close_last_send_time = #{ageCloseLastSendTime} where pcba_device_id = #{pcbaDeviceId}")
    Integer updateDeviceAgeCloseLastSendTime(@Param("ageCloseLastSendTime") Date ageCloseLastSendTime, @Param("pcbaDeviceId") Integer pcbaDeviceId);

    /**
     * 清除年限挂起状态
     */
    @Update("update " + DB1TableName.PCBA_DEVICE + " set age_close_status = null where pcba_device_id = #{pcbaDeviceId}")
    Integer clearDeviceAgeCloseStatus(@Param("pcbaDeviceId") Integer pcbaDeviceId);

    /**
     * 提交 高端线体年限审核
     */
    @Update("update " + DB1TableName.PCBA_DEVICE + " set loop_close_method = #{loopCloseMethod},loop_close_remark = #{loopCloseRemark},loop_close_files = #{loopCloseFiles},loop_close_status = 3,loop_close_uuid = #{loopCloseUuid} where pcba_device_id = #{pcbaDeviceId}")
    Integer goSubmitLoopClose(@Param("pcbaDeviceId")Integer pcbaDeviceId,@Param("loopCloseMethod")Integer loopCloseMethod,@Param("loopCloseRemark")String loopCloseRemark,@Param("loopCloseFiles")String loopCloseFiles,@Param("loopCloseUuid")String loopCloseUuid);

    /**
     * 提交 设备年限审核
     */
    @Update("update " + DB1TableName.PCBA_DEVICE + " set age_close_method = #{ageCloseMethod}, age_close_remark = #{ageCloseRemark},age_close_files = #{ageCloseFiles},age_close_status = 3,age_close_uuid = #{ageCloseUuid} where pcba_device_id = #{pcbaDeviceId}")
    Integer goSubmitAgeClose(@Param("pcbaDeviceId")Integer pcbaDeviceId,@Param("ageCloseMethod")Integer ageCloseMethod,@Param("ageCloseRemark")String ageCloseRemark,@Param("ageCloseFiles")String ageCloseFiles,@Param("ageCloseUuid")String ageCloseUuid);

    /**
     * 查询所有有资产编号的设备
     */
    @ResultMap(value = "pcbaDeviceResultMap")
    @Select("<script>" +
            "select * from " + DB1TableName.PCBA_DEVICE + " t1," + DB1TableName.PCBA_LINE + " t2 where t1.pcba_line_id = t2.pcba_line_id " +
            " and t1.asset_number is not null and t1.asset_number != \"\" " +
            "<if test='assetNumber != null and assetNumber != \"\" '>" +
            " and t1.asset_number like CONCAT('%',#{assetNumber},'%')" +
            "</if>" +
            "<if test='handledType != null and handledType == 1 '>" +
            " and DATEDIFF(CURDATE(), t1.product_time) > #{dayOfHighLine} " +
            "</if>" +
            "<if test='handledType != null and handledType == 2 '>" +
            " and DATEDIFF(CURDATE(), t1.product_time) > #{dayOfDevice} " +
            "</if>" +
            "<if test='pcbaDeviceTypeId != null and pcbaDeviceTypeId != \"\" '>" +
            " and t1.pcba_device_type_id = #{pcbaDeviceTypeId} " +
            "</if>" +
            "<if test=\"pcbaWorkShopList != null and pcbaWorkShopList.size() > 0 \">\n" +
            "                and t2.pcba_workshop_id in\n" +
            "                <foreach item=\"item\" index=\"index\" collection=\"pcbaWorkShopList\"\n" +
            "                         open=\"(\" separator=\",\" close=\")\">\n" +
            "                    #{item}\n" +
            "                </foreach>\n" +
            "            </if>\n" +
            " order by t1.create_time" +
            "<if test='begin != null and pageSize != null and pageSize != \"\" '>" +
            " limit #{begin}, #{pageSize}" +
            "</if>" +
            "</script>")
    //List<PcbaDevice> queryAllAssetNumberDevices(@Param("begin")Integer begin,@Param("pageSize")Integer pageSize,@Param("assetNumber")String assetNumber,@Param("handledType")Integer handledType,@Param("dayOfHighLine")Double dayOfHighLine,@Param("dayOfDevice")Double dayOfDevice);
    List<PcbaDevice> queryAllAssetNumberDevices(@Param("assetNumber")String assetNumber,@Param("handledType")Integer handledType,@Param("dayOfHighLine")Double dayOfHighLine,@Param("dayOfDevice")Double dayOfDevice,@Param("pcbaDeviceTypeId")Integer pcbaDeviceTypeId, @Param("pcbaWorkShopList")List<Integer> pcbaWorkShopList, @Param("begin") Integer begin, @Param("pageSize") Integer pageSize);
}
